<?php

namespace Admin\Controller;

/**
 * 系统设置模块控制器类
 *
 * 系统设置相关操作
 *
 * @author: xuhui <xuh86@126.com>
 * @version: $Id$
 * @package: asoc.Admin.Controller
 *
 */


class SystemController extends CommonController {
   
	/**
	* 设置网站配置信息
	*/
	public function webSet()
    {
		$act = $this->getString('act');
		if($act == 'save')
        {
			$sModel = M('SysWebconf');
			$data['company'] = $_POST['company'];
            $data['domain'] = $_POST['domain'];
            $sModel->where("`conf_id`=1")->save($data);

            if($_FILES['logo']['name'] != '')
            {
                $rs = $this->uploadFile('./sys/',2048);
                if($rs['status'] == 1)
                {
                    $filename = $rs['info']['logo']['savename'];
                    $data['logo'] = $filename;
                }
            }
            $sModel->where("`conf_id`=1")->save($data);

            echo 1;
		}
        else
        {
			$this->display();
		}
	}
	


    //修改密码
    public function changePassword()
    {
        if (isset($_POST['newpwd']))
        {
            $flag = 0;
            $admin = M('AdminUser');
            $adminId = session(C('BE_UID'));
            $postOldPWD = trim($_POST['oldpwd']);
            $newPWD = trim($_POST['newpwd']);
            $oldPWD = $admin->where("`user_id`={$adminId}")->getField('password');
            if($oldPWD == md5($postOldPWD))
            {
                $flag = 1;
                $admin->where("`user_id`={$adminId}")->setField('password',md5($newPWD));
            }
            else
            {
                $flag = 2;
            }
            echo $flag;



        }
        else
        {
            $this->display();
        }
    }


	
	
}